#include "./infodockelementsbuilder.h"
#include <QVBoxLayout>
#include "db/dbconnection.h"


QVector<QLayout *> InfoDockElementsBuilder::_prepareInfoLabel(QSqlRecord record)
{
    return QVector<QLayout *>();
}

void InfoDockElementsBuilder::_createLayoutFromRecord(QSqlRecord record, QVBoxLayout *box)
{
    QVector<QLayout*> info = _prepareInfoLabel(record);
    for(int j=0; j<info.size(); j++)
        box->addLayout(info[j]);
}

QLayout * InfoDockElementsBuilder::build()
{
    QVBoxLayout* box = new QVBoxLayout();
    if(!_model.isNull())
    {
        _model->setFilter(_modelFilter);
        _model->select();
        for(int i=0; i<_model->rowCount(); i++)
        {
            QSqlRecord rec = _model->record(i);
            _createLayoutFromRecord(rec, box);
        }
    }
    else
    {
        _createLayoutFromRecord(_rowRecord[0], box);
    }
    return box;
}

QLayout * InfoDockElementsBuilder::build(void* data)
{
    return build();
}
